home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
t_os
/
chit
/
chit_src.lzh
/
STR.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-05-23
|
10KB
|
346 lines
;===============================================
; str.asm 91-05-23
;===============================================
.386p
CODE segment public dword use32
CODE ends
DATA segment public dword use32
DATA ends
BSS segment public dword use32
BSS ends
DGROUP group DATA,BSS
;===============================================================
CODE segment
assume cs:CODE,gs:DGROUP
public disp_str
public disp_str2
public put_ank
public color_set
;---------------------------------------------------------------
disp_str proc near
;-----------------------------------------------
;in: ds:esi *string
; dx locate(dl=x,dh=y)
; bl color(high=back, low=font)
;out: ds:esi next *string
; edi next *vram (offset)
;break: nothing
;-----------------------------------------------
push eax
push ebx
push ecx
push edx
push ebp
push es
mov ax,120h
mov es,ax ;VRAM sel
movzx edi,dh
shl edi,13 ;edi=y*512*16
and edx,000000ffh
lea edi,[edi+edx*4] ;edi=*vram
movzx edx,bl
shr edx,4
mov edx,gs:[color_ptn+edx*4] ;back color
and ebx,0000000fh
mov ebx,gs:[color_ptn+ebx*4] ;font color
mov gs:[font_color],ebx
mov gs:[back_color],edx
align 4
disp_str_lp: movzx eax,byte ptr ds:[esi]
inc esi
and al,al ;al=0?
je disp_str_e ;yes
mov bl,gs:[sjis_tbl+eax]
and bl,SJIS1? ;sjis 1st byte?
je disp_ank ;no
movzx ebx,byte ptr ds:[esi]
mov bh,gs:[sjis_tbl+ebx]
and bh,SJIS2? ;sjis 2nd byte?
je disp_ank ;no
mov bh,al ;bx=sjis code
inc esi
add bh,bh ;sjis to jis
cmp bl,80h
adc bx,1f61h
add bl,7fh
jb short knf1
add bl,0a2h
knf1: and bh,7fh ;bx=jis code
push esi
push ds
mov ax,0100h
mov dx,1010h
call fword ptr fs:[00a0h] ;ds:esi=*font
mov ebx,gs:[font_color]
mov ebp,gs:[back_color]
mov ecx,16
align 4
disp_kanji_lp: movzx eax,byte ptr ds:[esi]
inc esi
mov eax,gs:[font_ptn+eax*4]
mov edx,eax
not edx
and eax,ebx
and edx,ebp
or eax,edx
mov es:[edi],eax
movzx eax,byte ptr ds:[esi]
inc esi
mov eax,gs:[font_ptn+eax*4]
mov edx,eax
not edx
and eax,ebx
and edx,ebp
or eax,edx
mov es:[edi+4],eax
add edi,512 ;next line
loop disp_kanji_lp
pop ds
pop esi
sub edi,512*16-8 ;next *vram
jmp disp_str_lp
disp_ank: call put_ank
jmp disp_str_lp
disp_str_e:
pop es
pop ebp
pop edx
pop ecx
pop ebx
pop eax
ret
disp_str endp
;---------------------------------------------------------------
disp_str2 proc near
;-----------------------------------------------
;in: ds:esi *string
; dx locate(dl=x,dh=y)
; ecx length
; bl color(high=back, low=font)
;out: ds:esi next *string
; edi next *vram (offset)
;break: nothing
;-----------------------------------------------
push eax
push ecx
push es
mov eax,esi ;keep *string
call disp_str
xchg eax,esi
sub eax,esi
dec eax ;esi=string length
sub ecx,eax
jbe short fill_sp_e
mov ax,120h
mov es,ax ;VRAM sel
mov al,20h ;space
fill_sp_lp: call put_ank
loop fill_sp_lp
fill_sp_e:
pop es
pop ecx
pop eax
ret
disp_str2 endp
;---------------------------------------------------------------
put_ank proc near
;-----------------------------------------------
;in: al ank code
; es:edi *vram
; gs:[font_color] font_color
; gs:[back_color] back_color
;out: edi next *vram (offset)
;break: nothing
;-----------------------------------------------
pushad
push ds
movzx esi,al
add esi,esi
lea esi,[3d800h+esi*8] ;esi=al*16+3d800h
mov ax,138h ;font rom sel
mov ds,ax ;ds:esi=*font
mov ebx,gs:[font_color]
mov ebp,gs:[back_color]
mov ecx,16
align 4
put_ank_lp: movzx eax,byte ptr ds:[esi]
inc esi
mov eax,gs:[font_ptn+eax*4]
mov edx,eax
not edx
and eax,ebx
and edx,ebp
or eax,edx
mov es:[edi],eax
add edi,512 ;next line
loop put_ank_lp
pop ds
popad
add edi,4 ;next *vram
ret
put_ank endp
;---------------------------------------------------------------
color_set proc near
;-----------------------------------------------
;in: bl color (back:font)
;out: gs:[font_color] font_color
; gs:[back_color] back_color
;break: nothing
;-----------------------------------------------
push ebx
push edx
movzx edx,bl
shr edx,4
mov edx,gs:[color_ptn+edx*4] ;back color
and ebx,0000000fh
mov ebx,gs:[color_ptn+ebx*4] ;font color
mov gs:[font_color],ebx
mov gs:[back_color],edx
pop edx
pop ebx
ret
color_set endp
;---------------------------------------------------------------
CODE ends
;===============================================================
DATA segment
;-----------------------------------------------
; 16色VRAMビットパタ-ン
;-----------------------------------------------
color_ptn dd 000000000h,011111111h,022222222h,033333333h
dd 044444444h,055555555h,066666666h,077777777h
dd 088888888h,099999999h,0AAAAAAAAh,0BBBBBBBBh
dd 0CCCCCCCCh,0DDDDDDDDh,0EEEEEEEEh,0FFFFFFFFh
font_ptn dd 000000000h,0F0000000h,00F000000h,0FF000000h
dd 000F00000h,0F0F00000h,00FF00000h,0FFF00000h
dd 0000F0000h,0F00F0000h,00F0F0000h,0FF0F0000h
dd 000FF0000h,0F0FF0000h,00FFF0000h,0FFFF0000h
dd 00000F000h,0F000F000h,00F00F000h,0FF00F000h
dd 000F0F000h,0F0F0F000h,00FF0F000h,0FFF0F000h
dd 0000FF000h,0F00FF000h,00F0FF000h,0FF0FF000h
dd 000FFF000h,0F0FFF000h,00FFFF000h,0FFFFF000h
dd 000000F00h,0F0000F00h,00F000F00h,0FF000F00h
dd 000F00F00h,0F0F00F00h,00FF00F00h,0FFF00F00h
dd 0000F0F00h,0F00F0F00h,00F0F0F00h,0FF0F0F00h
dd 000FF0F00h,0F0FF0F00h,00FFF0F00h,0FFFF0F00h
dd 00000FF00h,0F000FF00h,00F00FF00h,0FF00FF00h
dd 000F0FF00h,0F0F0FF00h,00FF0FF00h,0FFF0FF00h
dd 0000FFF00h,0F00FFF00h,00F0FFF00h,0FF0FFF00h
dd 000FFFF00h,0F0FFFF00h,00FFFFF00h,0FFFFFF00h
dd 0000000F0h,0F00000F0h,00F0000F0h,0FF0000F0h
dd 000F000F0h,0F0F000F0h,00FF000F0h,0FFF000F0h
dd 0000F00F0h,0F00F00F0h,00F0F00F0h,0FF0F00F0h
dd 000FF00F0h,0F0FF00F0h,00FFF00F0h,0FFFF00F0h
dd 00000F0F0h,0F000F0F0h,00F00F0F0h,0FF00F0F0h
dd 000F0F0F0h,0F0F0F0F0h,00FF0F0F0h,0FFF0F0F0h
dd 0000FF0F0h,0F00FF0F0h,00F0FF0F0h,0FF0FF0F0h
dd 000FFF0F0h,0F0FFF0F0h,00FFFF0F0h,0FFFFF0F0h
dd 000000FF0h,0F0000FF0h,00F000FF0h,0FF000FF0h
dd 000F00FF0h,0F0F00FF0h,00FF00FF0h,0FFF00FF0h
dd 0000F0FF0h,0F00F0FF0h,00F0F0FF0h,0FF0F0FF0h
dd 000FF0FF0h,0F0FF0FF0h,00FFF0FF0h,0FFFF0FF0h
dd 00000FFF0h,0F000FFF0h,00F00FFF0h,0FF00FFF0h
dd 000F0FFF0h,0F0F0FFF0h,00FF0FFF0h,0FFF0FFF0h
dd 0000FFFF0h,0F00FFFF0h,00F0FFFF0h,0FF0FFFF0h
dd 000FFFFF0h,0F0FFFFF0h,00FFFFFF0h,0FFFFFFF0h
dd 00000000Fh,0F000000Fh,00F00000Fh,0FF00000Fh
dd 000F0000Fh,0F0F0000Fh,00FF0000Fh,0FFF0000Fh
dd 0000F000Fh,0F00F000Fh,00F0F000Fh,0FF0F000Fh
dd 000FF000Fh,0F0FF000Fh,00FFF000Fh,0FFFF000Fh
dd 00000F00Fh,0F000F00Fh,00F00F00Fh,0FF00F00Fh
dd 000F0F00Fh,0F0F0F00Fh,00FF0F00Fh,0FFF0F00Fh
dd 0000FF00Fh,0F00FF00Fh,00F0FF00Fh,0FF0FF00Fh
dd 000FFF00Fh,0F0FFF00Fh,00FFFF00Fh,0FFFFF00Fh
dd 000000F0Fh,0F0000F0Fh,00F000F0Fh,0FF000F0Fh
dd 000F00F0Fh,0F0F00F0Fh,00FF00F0Fh,0FFF00F0Fh
dd 0000F0F0Fh,0F00F0F0Fh,00F0F0F0Fh,0FF0F0F0Fh
dd 000FF0F0Fh,0F0FF0F0Fh,00FFF0F0Fh,0FFFF0F0Fh
dd 00000FF0Fh,0F000FF0Fh,00F00FF0Fh,0FF00FF0Fh
dd 000F0FF0Fh,0F0F0FF0Fh,00FF0FF0Fh,0FFF0FF0Fh
dd 0000FFF0Fh,0F00FFF0Fh,00F0FFF0Fh,0FF0FFF0Fh
dd 000FFFF0Fh,0F0FFFF0Fh,00FFFFF0Fh,0FFFFFF0Fh
dd 0000000FFh,0F00000FFh,00F0000FFh,0FF0000FFh
dd 000F000FFh,0F0F000FFh,00FF000FFh,0FFF000FFh
dd 0000F00FFh,0F00F00FFh,00F0F00FFh,0FF0F00FFh
dd 000FF00FFh,0F0FF00FFh,00FFF00FFh,0FFFF00FFh
dd 00000F0FFh,0F000F0FFh,00F00F0FFh,0FF00F0FFh
dd 000F0F0FFh,0F0F0F0FFh,00FF0F0FFh,0FFF0F0FFh
dd 0000FF0FFh,0F00FF0FFh,00F0FF0FFh,0FF0FF0FFh
dd 000FFF0FFh,0F0FFF0FFh,00FFFF0FFh,0FFFFF0FFh
dd 000000FFFh,0F0000FFFh,00F000FFFh,0FF000FFFh
dd 000F00FFFh,0F0F00FFFh,00FF00FFFh,0FFF00FFFh
dd 0000F0FFFh,0F00F0FFFh,00F0F0FFFh,0FF0F0FFFh
dd 000FF0FFFh,0F0FF0FFFh,00FFF0FFFh,0FFFF0FFFh
dd 00000FFFFh,0F000FFFFh,00F00FFFFh,0FF00FFFFh
dd 000F0FFFFh,0F0F0FFFFh,00FF0FFFFh,0FFF0FFFFh
dd 0000FFFFFh,0F00FFFFFh,00F0FFFFFh,0FF0FFFFFh
dd 000FFFFFFh,0F0FFFFFFh,00FFFFFFFh,0FFFFFFFFh
;-----------------------------------------------
; 漢字コ-ドチェックテ-ブル
;-----------------------------------------------
SJIS1? equ 1
SJIS2? equ 2
; 0 1 2 3 4 5 6 7 8 9 A B C D E F
sjis_tbl db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;1
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;2
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;3
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 ;4
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 ;5
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 ;6
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0 ;7
db 2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 ;8
db 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 ;9
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 ;A
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 ;B
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 ;C
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 ;D
db 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 ;E
db 3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,0 ;F
;---------------------------------------------------------------
DATA ends
;===============================================================
BSS segment
font_color dd ?
back_color dd ?
BSS ends
;===============================================================
end